#include "rcc.h"
#include "rcc_hw.h"

void RCC_ResetAhb1(RCC_RstAhb1Enum ahb1)
{
	uint32_t val = ahb1;

	/* 复位寄存器需要由软件置一和清零 */
	SOC_RCC.AHB1RSTR = val;
	SOC_RCC.AHB1RSTR = 0;
}

void RCC_ResetAhb2(RCC_RstAhb2Enum ahb2)
{
	uint32_t val = ahb2;

	/* 复位寄存器需要由软件置一和清零 */
	SOC_RCC.AHB2RSTR = val;
	SOC_RCC.AHB2RSTR = 0;
}

void RCC_ResetAhb3(RCC_RstAhb3Enum ahb3)
{
	uint32_t val = ahb3;

	/* 复位寄存器需要由软件置一和清零 */
	SOC_RCC.AHB3RSTR = val;
	SOC_RCC.AHB3RSTR = 0;
}

void RCC_ResetApb1(RCC_RstApb1Enum apb1)
{
	uint32_t val = apb1;

	/* 复位寄存器需要由软件置一和清零 */
	SOC_RCC.APB1RSTR = val;
	SOC_RCC.APB1RSTR = 0;
}

void RCC_ResetApb2(RCC_RstApb2Enum apb2)
{
	uint32_t val = apb2;

	/* 复位寄存器需要由软件置一和清零 */
	SOC_RCC.APB2RSTR = val;
	SOC_RCC.APB2RSTR = 0;
}

void RCC_EnableAhb1(RCC_ClkAhb1Enum ahb1)
{
	uint32_t val = ahb1;

	SOC_RCC.AHB1ENR |= val;
}

void RCC_EnableAhb2(RCC_ClkAhb2Enum ahb2)
{
	uint32_t val = ahb2;

	SOC_RCC.AHB2ENR |= val;
}

void RCC_EnableAhb3(RCC_ClkAhb3Enum ahb3)
{
	uint32_t val = ahb3;

	SOC_RCC.AHB3ENR |= val;
}

void RCC_EnableApb1(RCC_ClkApb1Enum apb1)
{
	uint32_t val = apb1;

	SOC_RCC.APB1ENR |= val;
}

void RCC_EnableApb2(RCC_ClkApb2Enum apb2)
{
	uint32_t val = apb2;

	SOC_RCC.APB2ENR |= val;
}


void RCC_DisableAhb1(RCC_ClkAhb1Enum ahb1)
{
	uint32_t val = ahb1;

	SOC_RCC.AHB1ENR &= ~val;
}

void RCC_DisableAhb2(RCC_ClkAhb2Enum ahb2)
{
	uint32_t val = ahb2;

	SOC_RCC.AHB2ENR &= ~val;
}

void RCC_DisableAhb3(RCC_ClkAhb3Enum ahb3)
{
	uint32_t val = ahb3;

	SOC_RCC.AHB3ENR &= ~val;
}

void RCC_DisableApb1(RCC_ClkApb1Enum apb1)
{
	uint32_t val = apb1;

	SOC_RCC.APB2ENR &= ~val;
}

void RCC_DisableApb2(RCC_ClkApb2Enum apb2)
{
	uint32_t val = apb2;

	SOC_RCC.APB2ENR &= ~val;
}

